package com.shelpe.service.simbaproxy.mock;

import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.context.RequestContext;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class MockResponseSenderFilter extends ZuulFilter {

	@Override
	public boolean shouldFilter() {
		RequestContext cxt = RequestContext.getCurrentContext();
		return cxt.getBoolean("simbaproxy.mocked", false);
	}

	@Override
	public Object run() {
		log.debug("enable sendZuulResponse");
		RequestContext cxt = RequestContext.getCurrentContext();
		cxt.addZuulResponseHeader("Content-Type", "application/json;charset=UTF-8");
		cxt.setSendZuulResponse(true);
		return null;
	}

	@Override
	public String filterType() {
		return "post";
	}

	@Override
	public int filterOrder() {
		return 999;
	}

}
